package employee;

import java.util.Calendar;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;

public class AddNewEmployeeController {
	ObservableList<String> maritalStatusList=FXCollections.observableArrayList("single","Married","Divorced");
	
	ObservableList<String> mainDepartList=FXCollections.observableArrayList("Electrical","Mechanical");
	
	
	ObservableList<String> electricalList=FXCollections.observableArrayList("Design","R&D");
	ObservableList<String> mechanicalList=FXCollections.observableArrayList("Sales","Managment");
	@FXML
	private TextField nameField;
	
	@FXML
	private TextField addressField;
	@FXML
	private TextField cityField;
	@FXML
	private TextField phoneField;
	@FXML
	private TextField emailField;
	
	
	@FXML
	private DatePicker datePicker;
	
	
	@FXML
	private TextField ageField;
	
	@FXML
	private ChoiceBox<String> maritalStatus;
	
	@FXML
	private RadioButton maleBtn;
	
	@FXML
	private RadioButton femaleBtn;
	@FXML
	private TextField idField;
	@FXML
	private ComboBox<String> mainDepartmentBox;
	
	@FXML
	private ComboBox<String> departmentBox;
	
	@FXML
	private CheckBox checkBoxYes;
	
	@FXML
	private CheckBox checkBoxNO;
	
	
	@FXML
	private void initialize() {
		maritalStatus.setValue(maritalStatusList.get(0));
		maritalStatus.setItems(maritalStatusList);
		
		mainDepartmentBox.setValue(mainDepartList.get(0));
		mainDepartmentBox.setItems(mainDepartList);
		
		departmentBox.setValue(electricalList.get(0));
		departmentBox.setItems(electricalList);
		
	}
	
	@FXML
	private void showAge() {
		Calendar now=Calendar.getInstance();
		int year=now.get(Calendar.YEAR);
		int birthday=datePicker.getValue().getYear();
		int age=year-birthday;
		ageField.setText(Integer.toString(age)+" Years");
	}
	@FXML
	private void mainDepartmentChoice() {
		if(mainDepartmentBox.getValue().equals("Electrical")) {
			departmentBox.setValue(electricalList.get(0));
			departmentBox.setItems(electricalList);
		}else {
			departmentBox.setValue(mechanicalList.get(0));
			departmentBox.setItems(mechanicalList);
		}
	}
	
	@FXML
	private void handleYesBox() {
		if(checkBoxYes.isSelected()) {
			checkBoxNO.setSelected(false);
		}
	}
	
	@FXML
	private void handleNoBox() {
		if(checkBoxNO.isSelected()) {
			checkBoxYes.setSelected(false);
		}
	}



}
